public class Login {
    public String username = "bit";
    public String password = "123";

    public void loginInfo(String username, String password) throws UserNameException, PassWordException {
        if (!this.username.equals(username)) {
            throw new UserNameException("用户名有问题,你输入的用户名是: " + username);
        }

        if (!this.password.equals(password)) {
            throw new PassWordException("密码有问题,你输入的密码是: " + password);
        }

        System.out.println("登陆成功");
    }

    public static void main(String[] args) {
        Login login  = new Login();
        try {
            login.loginInfo("bit","1253");
        }catch (UserNameException e) {
            e.printStackTrace();
            System.out.println("捕获了 UserNameException 异常");
        }catch(PassWordException e) {
            e.printStackTrace();
            System.out.println("捕获了 PassWordException 异常");
        }
    }

    public static void func2() {
        try {
            int[] array = null;
            System.out.println(array.length);
        }catch (NullPointerException e) {
            try {
                int[] array = {1,2,3};
                System.out.println(array[9]);
            }catch (ArrayIndexOutOfBoundsException e2) {

            }
        }finally {
            System.out.println("hahahahah");
        }
    }

    public static void main1(String[] args) {
        func2();

        try {

        }finally {

        }


    }
}
